function FormApp(options) {
    //默认传入参数
    var defaultOptions = {
        layOutID: "",
        buttonAreaID: "",
        hiddenAreaId: "",
        parmMap: {},
        formConfig: {}
    };
    //最后更新时间
    var lsTime = null;
    var _this = this;
    var select_picker = {};
    var select_options = {};
    var date_picker = {};
    var _condition = '';
    var dateIsWhenNew = true;
    var loadData;
    var btns = [];
    var tableMap = {};
    var orgList = [];
    var ctrlTypeDischarged = ['appTable'];
    // 控件数据集合
    var ctrlDataSource = {};
    // 控件调用服务数据集合
    var ctrlLoadDataSource = [];
    //参数合并
    $.extend(defaultOptions, options);
    var formConfig = defaultOptions.formConfig;
    var groupBindTable = {};
    //取得最后更新时间
    this.getlsTime = function () {
        return lsTime;
    };
    //设置最后更新时间
    this.setlsTime = function (stime) {
        lsTime = stime
    };
    this.initialize = function () {
        this.initParmMap();
        this.rendLayout();
        this.loadFormData();
        this.loadCtrlsDataSource();
        this.initGroupTable();
        this.rendCtrls();
        this.clickGroup();
        this.bodyBindEvent();
        return loadData;
    };
    this.rendLayout = function () {
        var strResult = decodeURI(formConfig["sff_app_layout"]);
        strResult = page.replaceAll(strResult, "&lt;", "<");
        strResult = page.replaceAll(strResult, "&gt;", ">");
        if (strResult) {
            var arr = webApi.matchKeyList(strResult);
            var strKey = "";
            var strValue = "";
            if (arr != null) {
                for (var i = 0; i < arr.length; i++) {
                    strKey = arr[i];
                    strKey = strKey.replace("{", "").replace("}", "");
                    strValue = "<div id='" + strKey + "_container'></div>";
                    if (strValue != null) {
                        strResult = strResult.replace("{" + strKey + "}", strValue);
                    }
                }
            }
            $("#" + defaultOptions.layOutID).html(strResult);
        }
        //设置标题
        var sff_title = formConfig["sff_title"];
        if (sff_title) {
            $("#" + defaultOptions.titieId).text(sff_title);
        }
    };
    this.initParmMap = function () {
        var parmMap = defaultOptions.parmMap;
        //将默认的当前人和日期加入到替换队列中
        if (parmMap) {
            //
        } else {
            parmMap = {};
        }
        //解析用户id
        var userid = unescape(unescape(sessionStorage.getItem("_userid")));
        if (userid) {
            // userid = $.parseJSON(userid);
            // if (userid) {
            //   var strUserid = userid["user_id"];
            parmMap["userId"] = userid;
            parmMap["userID"] = userid;
            // }
        }
        //加入必要的全局默认环境变量值
        parmMap["username"] = sessionStorage.getItem("_uname");
        parmMap["datetime"] = format.getDateTime();
        parmMap["date"] = format.getDate();
        parmMap["year"] = format.getYear();
        parmMap["month"] = format.getYearMonth();
        parmMap["strdate"] = format.getDateToStr();
        parmMap["strdatetime"] = format.getDateTString();
        defaultOptions.parmMap = parmMap;
    };
    this.loadFormData = function () {
        var data = null;
        if (run_model != "1") {
            var strSystemCode = formConfig["csystem"];
            var table = formConfig["sff_db_name"];
            var cond = formConfig["sff_condition"];
            var vapMap = null;
            var parm = page.getUrlParamMap(cond);
            if (parm) {
                var val;
                for (var p in parm) {
                    val = parm[p];
                    if (val.indexOf("}") > 0) {
                        if (defaultOptions.parmMap) {
                            for (var pv in defaultOptions.parmMap) {
                                val = val.replace("{" + pv + "}", defaultOptions.parmMap[pv]);
                                if (val.indexOf("}") == -1) {
                                    parm[p] = val;
                                    break;
                                }

                            }
                        }
                    }
                }
                vapMap = parm;
            }
            var funName = initFormFunName(table);
            if (page.isnotNull(funName)) {
                var queryformParm = {
                    "funName": funName,
                    "funType": "C",
                    "valMap": vapMap
                };
                var formData = webApi.ajax("system.common.queryForm", queryformParm);
                if (formData && formData.status == "0") {
                    data = formData.result.data;
                    loadData = data;
                    dateIsWhenNew = false;
                    //最后更新时间
                    if (formData.lstime) {
                        lsTime = formData.lstime
                    }
                }
                return data;
            }
            var queryformParm = {
                "funName": table,
                "funSystem": strSystemCode,
                "valMap": vapMap
            };
            var formData = webApi.ajax("system.common.queryForm", queryformParm);
            if (formData && formData.status == "0") {
                data = formData.result.data;
                loadData = data;
                dateIsWhenNew = false;
                //最后更新时间
                if (formData.lstime) {
                    lsTime = formData.lstime
                }
            }
        } else {
            var json = decodeURI(page.getLocalStorage(formCode + "_dataquery"));
            var primary = $.parseJSON(json).config.main.primary;
            var primaryKey;
            if (defaultOptions.parmMap) {
                primaryKey = defaultOptions.parmMap[primary];
            }
            json = json.replaceAll('{primaryKey}', primaryKey);
            json = json.replaceAll('{primary}', primary);
            json = json.replaceAll('{' + primary + '}', primaryKey);
            var url = window.location.href;
            url = url.split('?')[1];
            var param = page.getUrlParamMap(url);
            delete param.t;
            var keyJson = $.parseJSON(json);
            for (var m in keyJson.config) {
                for (var p in param) {
                    keyJson.config[m].valMap[p] = param[p];
                }
            }
            json = JSON.stringify(keyJson);
            page.setLocalStorage(formCode + "_dataquery", json);//数据查询放进缓存
            var formData = webApi.ajax(initQueryDataUrl("system.common.billQuery"), initQueryData(json));
            var data;
            if (formData) {
                if (formData.status == "0") {
                    WO.dataSource = formData.result.data;
                    data = WO.dataSource.main;
                    loadData = data;
                } else {
                    dialogBox.alert("读取数据出错:" + formData.message);
                }
            } else {
                dialogBox.alert("读取数据出错:" + formData.message);
            }
        }
        return data;
    };
    this.dataAutoBinding = function (data) {
        if (!data) {
            data = {};
        }
        loadData = data;
        //进行默认值初始化
        data = _this.initCtrlDefaultValue(data);
        var result;
        if (typeof (data) == "string") {
            result = $.parseJSON(data)
        } else {
            result = data;
        }
        // 需要绑定的控件组
        var ctrlArgs = [];
        // 将json字符串中的key推入到需要绑定的控件组中
        for (var key in result) {
            ctrlArgs.push(key);
        }
        $.each(formConfig["sff_app_config"].Controls, function (index, e) {
            // 如果某控件的对应属性名包含在绑定控件组中，将对应的值绑定到控件上1
            if (($.inArray(e.propName, ctrlArgs) != -1) || ($.inArray(e.ctrlType, ctrlTypeDischarged) != -1)) {
                var value = result[e.propName];
                var text = result[e.propName + "_text"];
                _this.setCtrlValue(e, value, text);
            }
        });
    };
    this.initCtrlDefaultValue = function (data) {
        var value;
        var defaultValue;
        var defaultValueCover;
        $.each(formConfig["sff_app_config"].Controls, function (index, e) {
            value = data[e.propName];
            defaultValue = e.defaultValue;
            if (defaultValue) {
                defaultValue = _this.replaceMapAndData(defaultValue);
                //是否为空，是否必须
                defaultValueCover = e.defaultValueCover;
                if (!defaultValueCover) {
                    defaultValueCover = '1'
                }
                //为空时设置默认值
                if ("1" == defaultValueCover) {
                    if (!value) {
                        value = defaultValue;
                    }
                }
                //总是设置为默认值
                if ("2" == defaultValueCover) {
                    value = defaultValue;
                }
                if (value) {
                    data[e.propName] = value;
                }
            }
        });
        return data;
    };
    this.loadCtrlsDataSource = function () {
        if (run_model == '1') {
            return;
        }
        var dataSources = null;
        $.each(formConfig["sff_app_config"].Controls, function (index, e) {
            if (e.dataSources) {
                _this.getDataSourceJson(e, index);
            }
        });
        // 从服务器端批量请求数据
        if (ctrlLoadDataSource.length > 0) {
            var ajaxData = {
                "url": "common.bqueryList",
                "data": {
                    "valList": ctrlLoadDataSource
                }
            };
            var result = this.doAjax(ajaxData);
            if (result && result.status == "0") {
                result = result.result;
                if (result) {
                    var data = null;
                    for (var p in result) {
                        data = result[p];
                        if (data && data.status == "0") {
                            ctrlDataSource[p] = data.result.data;
                        }
                    }
                }
            }
        }
        for (var p in ctrlDataSource) {
            dataSources = ctrlDataSource[p];
            if (dataSources) {
                e = formConfig["sff_app_config"].Controls[p];
                // 进行树形层次转换
                if (e.ctrlType.toLocaleLowerCase != 'autocomplate') {
                    if (e.dataSources.prentItemField) {
                        dataSources = _this
                            .rendTreeOptions(
                                dataSources,
                                [],
                                e.dataSources.prentItemField,
                                e.dataSources.prentItemValue == undefined ? "-"
                                    : e.dataSources.prentItemValue,
                                0);
                    }
                    // 添加空选择项
                    if (e.dataSources.emptyItemText != null
                        && e.dataSources.emptyItemText != undefined) {
                        if (e.dataSources.emptyItemValue == null
                            || e.dataSources.emptyItemValue == undefined) {
                            e.dataSources["emptyItemValue"] = "";
                        }
                        dataSources.splice(0, -1, {
                            "value": e.dataSources.emptyItemValue,
                            "text": e.dataSources.emptyItemText
                        })
                    }
                }
                formConfig["sff_app_config"].Controls[p]["dataSources"]["data"] = dataSources;
            }
        }
    };
    this.initGroupTable = function () {
        var ctrlList = formConfig.sff_app_config.Controls;
        for (var i = 0; i < ctrlList.length; i++) {
            if (ctrlList[i].ctrlType == "group" && page.isnotNull(ctrlList[i].bandCtrlId)) {
                var isOpen = ctrlList[i].isOpen;
                for (var j = 0; j < ctrlList.length; j++) {
                    if (ctrlList[j].ctrlId == ctrlList[i].bandCtrlId) {
                        ctrlList[j]["isOpen"] = isOpen;
                        groupBindTable[ctrlList[j].ctrlId] = ctrlList[j];
                    }
                }
            }
        }
    };
    this.rendCtrls = function () {
        var html = "";
        var bIndex = 0;
        var ctrlsShow = [];
        $.each(formConfig["sff_app_config"].Controls, function (index, e) {
            //控件渲染
            switch (e.ctrlType.toLocaleLowerCase()) {
                case ("div"):
                    html = _this.getDiv(e);
                    break;
                case ("group"):
                    html = _this.getGroup(e);
                    break;
                case ("input"):
                    html = _this.getInput(e);
                    break;
                case ("select"):
                    html = _this.getSelect(e);
                    break;
                case ("checkbox"):
                    html = _this.getCheckBox(e);
                    break;
                case ("radio"):
                    html = _this.getRadio(e);
                    break;
                case ("refer"):
                    html = _this.getRefer(e);
                    break;
                case ("textarea"):
                    html = _this.getTextArea(e);
                    break;
                case ("date"):
                    html = _this.getDate(e);
                    break;
                case ("numbox"):
                    html = _this.getNumbox(e);
                    break;
                case ("switch"):
                    html = _this.getSwitch(e);
                    break;
                case ("button"):
                    btns.push(e);
                    html = _this.getButton(e);
                    break;
                case ("hidden"):
                    html = _this.getHidden(e);
                    break;
                case ("apptable"):
                    html = _this.getAppTable(e);
                    break;
                case ("userselect"):
                    html = _this.getUserSelect(e);
                    break;
                case ("appfileupload"):
                    html = _this.getFileUpload(e);
                    break;
                case ("record"):
                    boot.__loadNeed("record");
                    html = _this.getRecord(e);
                    break;
                default:
                    html = _this.getInput(e);
                    break;
            }
            if (e.ctrlType.toLocaleLowerCase() == "button") {
                //按钮去添加按钮
                if (page.checkOtherPlat().isOP) {
                    var weLinkBtnCtrl = $(".weLink-Btn");
                    if (weLinkBtnCtrl.length > 0) {
                        weLinkBtnCtrl.append(html);
                    }
                } else {
                    var buttonArea = $("#" + defaultOptions.buttonAreaID);
                    if (buttonArea.length > 0) {
                        buttonArea.find('.title-btn').append(html);
                    }
                }
            } else if (e.ctrlType.toLocaleLowerCase() == "hidden") {
                //页面添加隐藏对象
                $("#" + defaultOptions.hiddenAreaId).append(html);
            } else {
                //展示区添加显示控件
                if (formConfig["sff_app_layout"]) {
                    $("#" + e.ctrlId + "_container").append(html);
                    ctrlsShow.push(html)
                } else {
                    $("#" + defaultOptions.layOutID).append(html);
                }
            }
            if (e.ctrlType.toLocaleLowerCase() == 'select') {
                var pickerButton = document.getElementById(e.ctrlId);
                pickerButton.addEventListener('tap', function (event) {
                    var json = e.dataSources;
                    json.field = e.ctrlId;
                    json.formCode = formCode;
                    if (e.lazyload == "1") {
                        json = initDataSource(json);
                        webApi.ajax(initDataSourceUrl("system.common.billQuery"), json, function (data) {
                            if (data.status == "0") {
                                var options = [];
                                var dataJson = data.result.data;
                                $.each(dataJson, function (index, opt) {
                                    options.push(opt)
                                });
                                select_picker[e.ctrlId + "_select_picker"].setData(options);
                                select_picker[e.ctrlId + "_select_picker"].show(function (items) {
                                    pickerButton.innerHTML = items[0].text;
                                    pickerButton.setAttribute("value", items[0].value);
                                    if (e && e.events) {
                                        var eventList = e.events;
                                        for (var i = 0; i < eventList.length; i++) {
                                            eval(eventList[i].script + "(" + JSON.stringify(items[0]) + ")");//TODO 本身带参数，后续考虑有没有这种场景
                                        }
                                    }
                                });
                            }
                        });
                    } else {
                        select_picker[e.ctrlId + "_select_picker"].show(function (items) {
                            pickerButton.innerHTML = items[0].text;
                            pickerButton.setAttribute("value", items[0].value);
                            if (e && e.events) {
                                var eventList = e.events;
                                for (var i = 0; i < eventList.length; i++) {
                                    eval(eventList[i].script + "(" + JSON.stringify(items[0]) + ")");//TODO 本身带参数，后续考虑有没有这种场景
                                }
                            }
                        });
                    }
                }, false);
            }
            if (e.ctrlType.toLocaleLowerCase() == 'userselect') {
                $("#" + e.ctrlId).click(function () {
                    var oldUserList = $("#" + e.ctrlId).text();
                    _this.userSelectClick($(this).attr("id"), $(this).attr("selectMode"), oldUserList);
                });
            }
            if (dateIsWhenNew) {
                if (e.ctrlType.toLocaleLowerCase() == 'date') {
                    var pickerButton = document.getElementById(e.ctrlId);
                    pickerButton.addEventListener('tap', function (event) {
                        date_picker[e.ctrlId + "_date_picker"].show(function (items) {
                            var val = '';
                            if (items) {
                                val = items.value;
                                pickerButton.innerHTML = val;
                            } else {
                                pickerButton.innerHTML = '请选择';
                            }
                            date_picker[e.ctrlId + "_date_picker"].value = val;
                        });
                    }, false);
                }
            }
            if (defaultOptions.parmMap.hasOwnProperty("showbutton")) {
                //if(e.ctrlType=='button'){
                $("#btn_area").remove();
                //}
            }
            if (defaultOptions.parmMap.hasOwnProperty("showTop")) {
                $(".mui-searchRegion").remove();
                $(".mui-list-form").css("padding-top", "1px");
            }
            _this.bindCtrlEvent(e);

        })

        _this.bottomButtonRend();
    };
    this.bottomButtonRend = function () {
        var btnA = $("#btn_area");
        var weLinkMore = false;
        if (page.checkOtherPlat().isOP) {
            weLinkMore = true;
        }
        $.each(btns, function (index, e) {
            var html = '';
            if (btns.length == 1) {
                var strClass = "form-btn-1";
                if (weLinkMore) {
                    strClass = "form-btn-2";
                }
                html = "<button class = '" + e.ctrlId + "' id='" + e.ctrlId + '_bottom' + "' class='mui-btn mui-btn-primary form-btn-blue form-btn' type='button'>" + e.ctrlChnName + "</button>";
                btnA.addClass(strClass);
            } else if (btns.length == 2) {
                var strClass = "form-btn-2";
                if (weLinkMore) {
                    strClass = "form-btn-3";
                }
                html = "<button  class = '" + e.ctrlId + "' id='" + e.ctrlId + '_bottom' + "' class='mui-btn mui-btn-primary form-btn-blue ' type='button'>" + e.ctrlChnName + "</button>";
                btnA.addClass(strClass)
            } else if (btns.length > 2) {
                var strClass = "form-btn-3"
                if (weLinkMore) {
                    strClass = "form-btn-4";
                }
                if (index < 3) {
                    html = "<button  class = '" + e.ctrlId + "' id='" + e.ctrlId + '_bottom' + "' class='mui-btn mui-btn-primary form-btn-blue ' type='button'>" + e.ctrlChnName + "</button>";
                    btnA.addClass(strClass);
                }
            }
            btnA.append(html);
            if (defaultOptions.parmMap.hasOwnProperty("showbutton")) {
                if (e.ctrlType == 'button') {
                    $("." + e.ctrlId).css('display', 'none')
                }
            }
            _this.bindCtrlEvent(e);
        })
        if (weLinkMore) {
            var html = "<button id='WeLinkMore' class='mui-btn mui-btn-primary form-btn-blue ' type='button' onclick='weLinkMore()'>更多</button>";
            btnA.append(html);
        }
    };
    this.bindCtrlEvent = function (e) {
        switch (e.ctrlType.toLocaleLowerCase()) {
            case ("div"):
            case ("input"):
            case ("teatarea"):
            case ("date"):
            case ("select"):
            case ("checkbox"):
            case ("radio"):
            case ("img"):
            case ("button"):
                if (e && e.events) {
                    var ctrl = _this.getCtrl(e);
                    ;
                    var ctrlClass = $("." + e.ctrlId);
                    events = e.events;
                    for (var i = 0; i < events.length; i++) {
                        ctrl.attr(events[i].event, events[i].script);
                        ctrlClass.attr(events[i].event, events[i].script);
                    }
                }
                break;
            default:
                break;
        }
    };
    this.getDiv = function (e) {
        var html = "";
        if (e) {
            html = "<div id='" + e.ctrlId + "'></div>";
        }
        return html;
    };
    this.getGroup = function (e) {
        var html = "";
        if (e) {
            html = '<div id="' + e.ctrlId + '" style="overflow:hidden;height: 40px;">' +
                ' <p class="detailedTtitle" id="' + e.bandCtrlId + '_group">' + e.ctrlChnName + '</p>'
            //附件
            if (e.isUpLoad == '1') {
                html += '  <p class="detailedFileBtn">附件</p>';
            }
            //新增
            if (e.isAdd == '1') {
                html += '  <p class="detailedAddBtn">新增</p>';
            }
            //后续可继续扩展，控件注册配置
            html += ' <input type="hidden" id="' + e.ctrlId + '_isOpen" value="' + e.isOpen + '" />';
            html += ' <input type="hidden" id="' + e.ctrlId + '_bandCtrlId" value="' + e.bandCtrlId + '" />';
            html += ' </div>';
        }
        return html;
    };
    this.getInput = function (e) {
        var html = "";
        if (e) {
            var showType = e.showType;
            var placeholder = e.placeholder;
            var isClear = e.isClear;
            var inputClass = e.cssClass;
            if (!placeholder) {
                placeholder = '请输入...';
            }
            if (isClear == '1') {
                inputClass = inputClass + "mui-input-clear"
            }
            //非空标识
            var unNullMark = this.getUnNullMark(e);
            if (showType == 'password') {
                html = "<div class='mui-input-row mui-password'>" +
                    "<label>" + e.ctrlChnName + unNullMark + "</label>" +
                    "<input id='" + e.ctrlId + "'type='password' placeholder=\"" + placeholder + "\" class='mui-input-password'>" +
                    "</div>"
            } else {
                html = "<div class='mui-input-row'>" +    //表单
                    "<label>" + e.ctrlChnName + unNullMark + "</label>" +
                    "<input id='" + e.ctrlId + "'type='text' placeholder=\"" + placeholder + "\" class=\"form-control " + inputClass + "\">" +
                    "<p class='tishi' id='" + e.ctrlId + "_check'>" + e.ctrlChnName + "不能为空</p>" +
                    "</div>"
            }
            return html;
        }
    };
    //用户选择
    this.getUserSelect = function (e) {
        var html = "";
        if (e) {
            var strClass = e.cssClass;
            if (!strClass) {
                strClass = '';
            }

            var selectMode = "s";
            if (e.selectMode) {
                selectMode = e.selectMode;
            }
            var unNullMark = this.getUnNullMark(e);
            html = "<div class='mui-input-row'>" +
                "<label>" + e.ctrlChnName + unNullMark + "</label>" +
                "<i class='mui-icon mui-icon-arrowright'></i>" +
                "<button id='" + e.ctrlId + "' selectMode =\"" + selectMode + "\" type='button' >请选择</button>" +
                "</div>"

        }
        return html;
    };
    this.getRecord = function (e) {
        var html = "";
        if (e) {
            var appForm = $(".mui-input-group");
            if (appForm && appForm.length > 0) {
                var recordDiv = document.getElementById("recordDiv");
                if (!recordDiv) {
                    appForm.append('<div id="recordDiv" ><img src="../../images/luyin.gif" alt="" ><p>录音中······</p></div>');
                }
            }
            var bandModelId = _this.replaceMapAndData(e.bandModelId);
            html = '<div class="form-btn-2">\n' +
                '    <input id="' + e.ctrlId + '_start" type="button" style="background: #39b54a;width: 46%;margin-left: 10px;border-radius: 0.2rem" value="按住 说话"/>\n' +
                '    <input id="' + e.ctrlId + '_play" type="button" style="background: #39b54a;width: 46%;margin-left: 10px;border-radius: 0.2rem" value="播放"/>\n' +
                '</div>';
        }
        return html;
    };
    //文件上传
    this.getFileUpload = function (e) {
        var html = "";
        var u = navigator.userAgent;
        var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;
        if (e) {
            var bandModelId = _this.replaceMapAndData(e.bandModelId);
            var bandGroupId = _this.replaceMapAndData(e.bandGroupId);
            if (bandGroupId.indexOf("{") >= 0) {
                bandGroupId = 'V1.0';
            }
            if (isAndroid) {
                html = '<div id="' + e.ctrlId + '">' +
                    '<div class="mui-input-row">' +
                    '<label style="color: #333;">附件</label>' +
                    '<p id="' + e.ctrlId + '_upload_button" type="button" onclick="javascript:uploadImgFiles(\'' + e.fileConfigCode + '\',\'' + e.fileDirectory + '\',\'' + bandModelId + '\',\'' + bandGroupId + '\',\'' + e.ctrlId + '\')" class="fileUpload upload_fileImgBtn" style="width: 60px!important;border-radius:30px!important;border: #0a70c4 1px dashed;float:right">上传</p>' +
                    '</div>' +
                    '<div><ul class="fileUL" id="' + e.ctrlId + '_upload_ul">' +
                    '</ul>' +
                    '</div></div>';
            } else {
                html = '<div id="' + e.ctrlId + '">' +
                    '<div class="mui-input-row">' +
                    '<label style="color: #333;">附件</label>' +
                    '<button id="' + e.ctrlId + '_upload_button" type="button" class="fileUpload" style="width: 60px!important;border-radius:30px!important;border: #0a70c4 1px dashed;">上传</button>' +
                    '<input type="file" value="上传" id="' + e.ctrlId + '_upload_input" name="file" accept="*" multiple="multiple" style="display:none;opacity:0" ' +
                    'onchange="inputFileUpload(\'' + e.fileConfigCode + '\',\'' + e.fileDirectory + '\',\'' + bandModelId + '\',\'' + bandGroupId + '\',\'' + e.ctrlId + '\')"/>' +
                    '</div>' +
                    '<div><ul class="fileUL" id="' + e.ctrlId + '_upload_ul">' +
                    '</ul>' +
                    '</div></div>';
            }

        }
        return html;
    };
    this.getTextArea = function (e) {
        var html = "";
        if (e) {
            var placeholder = e.placeholder;
            var rows = e.rows;
            if (!placeholder) {
                placeholder = '';
            }
            if (!rows) {
                rows = 3;
            }
            //非空标识
            var unNullMark = this.getUnNullMark(e);
            html = "<div class='mui-input-row form-textarea'>" +
                "<label>" + e.ctrlChnName + unNullMark + "</label>" +
                "<textarea id='" + e.ctrlId + "' rows='" + rows + "' placeholder='" + placeholder + "'></textarea>" +
                "<p class='tishi' id='" + e.ctrlId + "_check'>" + e.ctrlChnName + "不能为空</p>" +
                "</div>"
        }
        return html;
    };
    this.getRadio = function (e) {
        var html = "";
        if (e) {
            var strClass = e.cssClass;
            if (!strClass) {
                strClass = '';
            }
            var dataJson = e.dataSources.data;
            //非空标识
            var unNullMark = this.getUnNullMark(e);
            if (dataJson) {
                html += "<div class='form-radio'>";
                $.each(dataJson, function (index, rdo) {
                    if (index == 0) {
                        html += "<h5 class='mui-content-padded'>" + e.ctrlChnName + unNullMark + "</h5>"
                    }

                    html += "<div class='mui-input-row mui-radio'><label>" + rdo.text + "</label><input id=\"" + e.ctrlId + "\" name=\"" + e.ctrlId + "_group\" type='radio' value='" + rdo.value + "'/></div>";
                });
                html += "<p class='tishi' id='" + e.ctrlId + "_check'>" + e.ctrlChnName + "</p>" +
                    "</div>";
            }
        }
        return html;
    };
    // 参照控件隐藏框
    this.getRefer = function (e) {
        var html = [];
        if (e) {
            var placeholder = '';
            if (e.placeholder != undefined) {
                placeholder = e.placeholder;
            }
            //非空标识
            var unNullMark = this.getUnNullMark(e);
            html.push("<div class='mui-input-row'>")
            html.push("<label>" + e.ctrlChnName + unNullMark + "</label>")
            html.push("<input type='hidden' id='");
            html.push(e.ctrlId);
            html.push("'>");
            var extClass = "";
            if (e.cssClass) {
                extClass = e.cssClass;
            }
            html.push("<input class='form-control" + extClass + "' type='text' disabled='disabled' id='");
            html.push(e.ctrlId + "_text' placeholder='" + placeholder + "'>");
            html.push("</div>")
        }
        return html.join("");
    },
        this.getCheckBox = function (e) {
            var html = "";
            if (e) {
                var strClass = e.cssClass;
                if (!strClass) {
                    strClass = '';
                }
                var dataJson = e.dataSources.data;
                //非空标识
                var unNullMark = this.getUnNullMark(e);
                if (dataJson) {
                    html += "<div class='form-radio'>";
                    $.each(dataJson, function (index, chk) {
                        if (index == 0) {
                            html += "<h5 class='mui-content-padded'>" + e.ctrlChnName + unNullMark + "</h5>";
                        }
                        html += "<div class='mui-input-row mui-checkbox'><label>" + chk.text + "</label><input name=\"" + e.ctrlId + "\"  id=\"" + e.ctrlId + "\" type='checkbox' value='" + chk.value + "'/></div>"
                    });
                    html += "</div>";
                }
            }
            return html;
        };
    this.getSelect = function (e) {
        var html = "";
        if (e) {
            //样式
            var strClass = e.cssClass;
            if (!strClass) {
                strClass = '';
            }
            var showPickerType = e.showPickerType;
            if (!showPickerType) {
                showPickerType = 1
            }
            //非空标识
            var unNullMark = this.getUnNullMark(e);
            var ctrlId = e.ctrlId;
            html = "<div class='mui-input-row'>" +
                "<label>" + e.ctrlChnName + unNullMark + "</label>" +
                "<i class='mui-icon mui-icon-arrowright'></i>" +
                "<button id='" + ctrlId + "' class='" + strClass + "' type='button'>请选择</button>" +
                "<p class='tishi' id='" + e.ctrlId + "_check'>" + e.ctrlChnName + "不能为空</p>" +
                "</div>"
            var csp = ctrlId + "_select_picker";
            if (page.isnotNull(e.isShowSearchBox) && e.isShowSearchBox == "1") {
                csp = new mui.PopPicker({
                    layer: showPickerType,
                    needSearch: true
                });
            } else {
                csp = new mui.PopPicker({
                    layer: showPickerType,
                    needSearch: false
                });
            }

            select_picker[ctrlId + "_select_picker"] = csp;
            csp.setData(_this.getOptions(e));
        }
        return html;
    };
    this.getDate = function (e) {
        var html = "";
        if (e) {
            var options;
            var date_options = e.date_options;
            var ctrlId = e.ctrlId;

            if (!date_options) {
                options = {
                    "type": "date"
                };
            } else {
                options = {
                    "type": date_options
                };
            }
            //非空标识
            var unNullMark = this.getUnNullMark(e);
            html = "<div class='mui-input-row'>" +
                "<label>" + e.ctrlChnName + unNullMark + "</label>" +

                "<i class='mui-icon mui-icon-arrowright'></i>" +
                "<button id='" + ctrlId + "' type='button' >请选择</button>" +
                "<p class='tishi' id='" + ctrlId + "_check'>" + e.ctrlChnName + "不能为空</p>" +
                "</div>"
        }
        //if (dateIsWhenNew) {
        var cdp = new mui.DtPicker(options);
        date_picker[ctrlId + "_date_picker"] = cdp;
        //}
        return html;
    };
    this.getNumbox = function (e) {
        var html = "";
        if (e) {
            var data_numbox_min = e.data_numbox_min;
            var data_numbox_max = e.data_numbox_max;
            var data_numbox_step = e.data_numbox_step;
            if (!data_numbox_min) {
                data_numbox_min = 0;
            }
            if (!data_numbox_max) {
                data_numbox_max = 9999;
            }
            if (!data_numbox_step) {
                data_numbox_step = 1;
            }
            //非空标识
            var unNullMark = this.getUnNullMark(e);
            html = "<div class='form-numbox'><div class='mui-input-row'>" +
                "<label>" + e.ctrlChnName + unNullMark + "</label>" +
                "<div id='" + e.ctrlId + "' class='mui-numbox' data-numbox-min='" + data_numbox_min + "' data-numbox-max='" + data_numbox_max + "' data-numbox-step='" + data_numbox_step + "'>" +
                "<button class='mui-btn mui-btn-numbox-minus' type='button'>&minus;</button>" +
                "<input class='mui-input-numbox' type='number'/>" +
                "<button class='mui-btn mui-btn-numbox-plus' type='button' style='margin-right:0'>+</button>" +
                "</div>" +
                "</div>" +
                "</div>"
        }
        return html;
    };
    this.getSwitch = function (e) {
        var html = "";
        if (e) {
            //非空标识
            var unNullMark = this.getUnNullMark(e);
            html = "<div class='mui-input-row'>" +
                "<label>" + e.ctrlChnName + unNullMark + "</label>" +
                "<div id='" + e.ctrlId + "'class='mui-switch mui-switch-blue mui-switch-mini'><div class='mui-switch-handle'></div></div>" +
                "</div>"
        }
        return html;
    };
    this.getButton = function (e, btnSum) {
        var html = '';
        var btnClass = e.btnClass;
        if (!btnClass) {
            btnClass = "mui-btn mui-btn-primary";
        }
        if (e) {
            html = "<button class = '" + e.ctrlId + "' id='" + e.ctrlId + "' class='" + btnClass + " " + e.ctrlId + "' type='button'>" + e.ctrlChnName + "</button>";
        }
        return html;
    };
    this.getHidden = function (e) {
        var html = "";
        if (e) {
            html = "<input type='hidden' id='" + e.ctrlId + "' />";
        }
        return html;
    };
    this.getAppTable = function (e) {
        var html = "";
        if (e) {
            html += '<div class="mui-content" id="mui-body" style="overflow:auto;';
            if (e.height) {
                html += 'height:' + parseInt(e.height) + "px;";
            }

            html += '">';
            html += '<div id="' + e.ctrlId + '_appTable" class="mui-list-content ' + e.cssClass + ' " style="background: #fff;"></div>';
            html += '</div>';
        }
        return html;
    };

    this.getUnNullMark = function (e) {
        var UnNullMark = "";
        if (e.validations != undefined && e.validations.nullEmptyCheck == "true") {
            var markId = e.ctrlId + "_unNullMark";

            // 设置提示标识html文本
            UnNullMark = "<span id=\"" + markId + "\" class=\"CustomUnEmptyStar\">*</span>";
        }
        return UnNullMark;
    };
    this.getDataSourceJson = function (e, index) {
        var sourceConfig = e.dataSources;
        var result = null;
        if (sourceConfig != undefined
            && sourceConfig.sourceType != undefined) {
            switch (sourceConfig.sourceType.toLocaleLowerCase()) {
                case ("url"):
                    // 自定义服务请求
                    result = this.doAjax(sourceConfig.data);
                    if (result && result.status == "0") {
                        result = result.result.data;
                    }
                    break;
                case ("json"):
                    // json配置
                    if (sourceConfig.data) {
                        if (typeof (sourceConfig.data) == "string") {
                            result = $.parseJSON(sourceConfig.data)
                        } else {
                            result = sourceConfig.data;
                        }
                    }
                    break;
                case ("function"):
                    // 方法调用
                    result = eval(sourceConfig.data);
                    break;
                case ("dic"):
                    // 数据字典
                    this.getDicList(sourceConfig.data, index);
                    break;
                case ("list"):
                    // 列表配置
                    result = this.getStrList(sourceConfig.data);
                    break;
                case ("config"):
                    // 自定义配置
                    // 进行参数替换
                    var parmMap = null;
                    if (sourceConfig.parm) {
                        parmMap = page.getUrlParamMap(sourceConfig.parm);
                        if (parmMap) {
                            for (var p in parmMap) { //
                                parmMap[p] = this.replaceMapAndData(parmMap[p]);
                            }
                        }
                    }
                    // 结果请求
                    var _sourceConfig = {
                        "funName": sourceConfig.data,
                        "keyName": index,
                        "funType": "C",
                        "valMap": parmMap,
                        "orderBys": e.orderBys
                    };
                    // 放入待批处理请求列表
                    ctrlLoadDataSource.push(_sourceConfig);
                    break;
                default:
                    break;
            }
            if (result) {
                ctrlDataSource[index] = result;
            }

        }
    };
    /*
     * 利用ajax向后台发送get请求 param url:请求地址 return:请求响应的数据
     */
    this.doAjax = function (ajaxData) {
        var returnJson = webApi.ajax(ajaxData.url, ajaxData.data,
            ajaxData.onSuccess, ajaxData.onFailure);
        if (returnJson) {
            if (returnJson.status != "0") {
                //alert(returnJson.message);
                returnJson = null;
            }
        } else {
            returnJson = null;
        }
        return returnJson;
    };
    // 字典查询配置并统一调用
    this.getDicList = function (strDic, index) {
        var keyPath = "System/Config/DicData"
        var sourceConfig = {
            "funName": "queryParamList",
            "keyName": index,
            "keyPath": keyPath,
            "vKey": strDic,
            "funType": "C",
            "valMap": {
                "type": strDic
            },
            "orderBys": "CIndex"
        };
        // 放入待批处理请求列表
        ctrlLoadDataSource.push(sourceConfig);
    };
    //value1,value2格式数据转换成数组
    this.getStrList = function (strList) {
        var list = new Array();
        if (strList != null && strList != "") {
            var templist = strList.split(",");
            for (var i = 0; i < templist.length; i++) {
                list.push({
                    "value": templist[i],
                    "text": templist[i]
                });
            }
        }
        return list;
    };
    this.replaceMapAndData = function (strInput) {
        var re = /{(.*?)}/g;
        var reg = /^\{/gi;
        var reg2 = /\}$/gi;
        var tempList = re.exec(strInput);
        if (tempList && tempList.length > 0) {
            var parmMap = defaultOptions.parmMap;
            var temp;
            var replaceValue;
            for (var i = 0; i < tempList.length; i++) {
                temp = tempList[i];
                temp = temp.replace(reg, '');
                temp = temp.replace(reg2, '');
                //参数取值
                replaceValue = parmMap[temp];
                if (!replaceValue) {
                    //结果集取值
                    if (loadData) {
                        replaceValue = loadData[temp]
                    }
                }
                if (replaceValue) {
                    strInput = strInput.replace("{" + temp + "}", replaceValue);
                }

            }
        }
        return strInput
    };
    this.getOptions = function (e) {
        var options = [];
        var emptyItemText = e.emptyItemText;
        var emptyItemValue = e.emptyItemValue;
        if (e && e.dataSources && e.dataSources.data) {
            var dataJson = e.dataSources.data;
            if (emptyItemText) {
                if (!emptyItemValue) {
                    emptyItemValue = ''
                }
                option = {
                    "text": emptyItemText,
                    "value": emptyItemValue
                };
                options.push(option)
            }
            if (e.lazyload != "1") {
                $.each(dataJson, function (index, opt) {
                    options.push(opt)
                });
            }
        }
        select_options[e.ctrlId] = options;
        return options;
    };
    this.getOptionsText = function (ctrlId, value, text) {
        var options = select_options[ctrlId];
        if (options == null || options.length <= 0) {

            return page.isnotNull(text) ? text : "";
        }
        for (var i = 0; i < options.length; i++) {
            if (options[i].value == value) {
                text = options[i].text;
                break;
            }
        }
        return text;
    };
    this.getAppFormData = function () {
        if (!_this.requestDataValidation(formConfig["sff_app_config"].Controls)) {
            return null;
        }
        var requestControl = {};
        $.each(formConfig["sff_app_config"].Controls, function (index, e) {
            // 如果该控件是需要格式化的控件，
            // 将key（控件对应请求对象名称），value（控件值）放入待返回json对象中
            if (e.ctrlType != "button" && e.propName != undefined) {
                var ctrlVal = _this.getCtrlValue(e);
                if (ctrlVal != null)
                    requestControl[e.propName] = ctrlVal;
            }
            if (e.killSpace) {
                if (e.killSpace == "1") {
                    requestControl[e.propName] = $.trim(ctrlVal);
                }
            }
        });
        return requestControl;
    };
    this.setConditionMode = function (condition) {
        if (condition) {
            _condition = condition;
            if (formConfig["sff_app_config"] && formConfig["sff_app_config"].conditions) {
                var condition = formConfig["sff_app_config"].conditions[condition];
                if (!condition) {
                    condition = "all";
                }
                if (condition) {
                    var ctrl;
                    $.each(formConfig["sff_app_config"].Controls, function (index, e) {
                        ctrl = _this.getCtrl(e);
                        ;
                        if (_this.isReadOnlyControl(condition, e.ctrlId) || defaultOptions.parmMap.hasOwnProperty("readonly")) {
                            ctrl.attr("disabled", "disabled");
                            $("#" + e.ctrlId + "_container").find(".mui-icon-arrowright").attr("disabled", "disabled");
                            $("#" + e.ctrlId + "_container").find("textarea").css("color", "#616367");
                            $("#" + e.ctrlId + "_container").find("button").css("margin-right", "16px");
                            $("#" + e.ctrlId + "_container").find("input").css("margin-right", "16px");
                            $("#" + e.ctrlId + "_container").find(".mui-btn-numbox-plus").css("margin-right", "0");
                        } else {
                            ctrl.removeAttr("disabled");
                            //$("#" + e.ctrlId + "_container").find(".mui-icon-arrowright").css("display", "");
                        }
                    });
                }
            }


        }
    };
    this.requestDataValidation = function (conditions) {
        var result = true;

        $.each(formConfig["sff_app_config"].Controls, function (index, e) {

            // 控件在该场景是否只读
            var isReadOnly = _this.isReadOnlyControl(conditions, e.ctrlId);

            // 如果控件非只读且需要验证
            if (!isReadOnly && e.validations != undefined) {
                var errMsg = "";

                // 对控件的配置信息对应的内容进行验证
                errMsg += _this.valueCheck(e);
                if (errMsg != "") {
                    //mui.alert(errMsg, '提示', '确定', null, 'div');
                    $("#" + e.ctrlId + "_check").show();
                    setTimeout(function () { //定时器
                            $("#" + e.ctrlId + "_check").animate({
                                right: '-300px'
                            }, 1500); //将图片的display属性设置为none
                            $("#" + e.ctrlId + "_check").hide();
                        },
                        1000); //设置三千毫秒即3秒
                    result = false;
                }
            }
        });
        return result;
    };
    this.valueCheck = function (e) {
        var errMsg = "";

        // 获取验证部分配置信息
        var valid = e.validations;
        var ele = this.getCtrlValue(e);

        // 正则验证
        if (page.isnotNull(valid.regular)) {
            var regular = '';
            if (page.isnotNull(valid.regular)) {
                regular = valid.regular;
                var regx = new RegExp(regular);
                if (!regx.test(ele)) {
                    if (page.isnotNull(valid.errMsg)) {
                        errMsg += valid.errMsg;
                    } else {
                        errMsg += e.ctrlChnName + "录入格式不正确；";
                    }
                    $("#" + e.ctrlId + "_check").text(errMsg);

                }
            }

        }
        if (e.ctrlType == 'date') {
            ele = $("#" + e.ctrlId + "").text();
            if (ele == "请选择") {
                ele = "";
            }
        }

        // 空值验证
        if (valid.nullEmptyCheck == "true") {
            if (ele == null || ele == "") {
                errMsg += e.ctrlChnName + "不允许为空；";
                $("#" + e.ctrlId + "_check").text(errMsg);
            }
        }

        // 最短长度验证
        if (valid.minLength != "" && valid.minLength) {
            if (ele.length < Number(valid.minLength)) {
                errMsg += e.ctrlChnName + "的长度不得小于" + Number(valid.minLength) + "；";
                $("#" + e.ctrlId + "_check").text(errMsg);
            }
        }


        // 最大长度验证
        if (valid.maxLength != "" && valid.maxLength) {
            if (ele.length > Number(valid.maxLength)) {
                errMsg += e.ctrlChnName + "的长度不得大于" + valid.maxLength + "；";
                $("#" + e.ctrlId + "_check").text(errMsg);
            }
        }


        return errMsg;
    };
    this.isReadOnlyControl = function (conditions, ctrlId) {
        var isReadOnly = false;
        if (conditions.indexOf(ctrlId) != -1 || conditions == "AllControls") {
            isReadOnly = true;
        }
        return isReadOnly;
    };
    this.getCtrlValue = function (e) {
        var ctrler = this.getCtrl(e);
        ;
        var result = "";
        switch (e.ctrlType.toLocaleLowerCase()) {
            case ("div"):
                result = ctrler.html();
                break;
            case ("date"):
                if (date_picker[e.ctrlId + "_date_picker"] && date_picker[e.ctrlId + "_date_picker"].value && date_picker[e.ctrlId + "_date_picker"].getSelected() && date_picker[e.ctrlId + "_date_picker"].getSelected().value) {
                    result = date_picker[e.ctrlId + "_date_picker"].getSelected().value
                } else {
                    result = ''
                }
                break;
            case ("select"):
                //result = select_picker[e.ctrlId + "_select_picker"].getSelectedItems()[0].value;
                result = $("#" + e.ctrlId).val();
                break;
            case ("input"):
            case ("textarea"):
            case ("hidden"):
                result = ctrler.val();
                if (result == null) {
                    result = "";
                }
                break;
            case ("numbox"):
                result = mui('#' + e.ctrlId).numbox().getValue();
                break;
            case ("switch"):
                var isActive = document.getElementById(e.ctrlId).classList.contains("mui-active");
                result = isActive ? '1' : '0';
                break;
            case ("checkbox"):
                if (ctrler) {
                    for (var i = 0; i < ctrler.length; i++) {
                        if (ctrler[i].checked) {
                            if (result == "") {
                                result = ctrler[i].value;
                            } else {
                                result += "," + ctrler[i].value;
                            }
                        }
                    }
                }
                break;
            case ("radio"):
                if (ctrler) {
                    for (var i = 0; i < ctrler.length; i++) {
                        if (ctrler[i].checked) {
                            result = ctrler[i].value;
                            break;
                        }
                    }
                }
                break;
            default:
                result = ctrler.text();
        }
        return result;
    };
    this.setCtrlValue = function (e, value, text) {
        var ctrler = this.getCtrl(e);
        switch (e.ctrlType.toLocaleLowerCase()) {
            case ("div"):
                ctrler.text(value);
                break;
            case ("group"):
                break;
            case ("select"):
                text = _this.getOptionsText(e.ctrlId, value, text);
                if (!page.isnotNull(text)) {
                    text = page.isnotNull(e.dataSources.emptyItemText) ? e.dataSources.emptyItemText : "";
                    value = page.isnotNull(e.dataSources.emptyItemValue) ? e.dataSources.emptyItemValue : value;
                }
                select_picker[e.ctrlId + "_select_picker"].pickers[0].setSelectedValue(value, 2000);
                var select_button = document.getElementById(e.ctrlId);
                select_button.innerHTML = text;
                document.getElementById(e.ctrlId).value = value;
                break;
            case ("refer"):
                $("#" + e.ctrlId).attr("value", value);
                $("#" + e.ctrlId + '_text').attr("value", text);
                break;
            case ("date"):
                if (!dateIsWhenNew) {
                    var date_options = e.date_options;
                    var options = {};
                    if (!date_options) {
                        options.type = "datetime";
                    } else {
                        options.type = date_options
                    }
                    var ctrlId = e.ctrlId;
                    var cdp = new mui.DtPicker(options);
                    date_picker[ctrlId + "_date_picker"] = cdp;
                    cdp.setSelectedValue(value);
                    var pickerButton = document.getElementById(ctrlId);
                    pickerButton.innerHTML = value;
                    pickerButton.addEventListener('tap', function (event) {
                        cdp.show(function (items) {
                            var val = '';
                            if (items) {
                                val = items.value;
                                pickerButton.innerHTML = val;
                            } else {
                                pickerButton.innerHTML = '请选择';
                            }
                            cdp.value = val;
                        });
                    }, false);
                    cdp.value = value
                }
                document.getElementById(e.ctrlId).innerHTML = value;
                ctrler.val(value);
                break;
            case ("input"):
            case ("textarea"):
            case ("hidden"):
                ctrler.val(value);
                break;
            case ("numbox"):
                mui("#" + e.ctrlId).numbox().setValue(value);
                break;
            case ("switch"):
                mui("#" + e.ctrlId)[0].setAttribute("value", value);
                if ('1' == value) {
                    $("#" + e.ctrlId).addClass("mui-active");
                }
                break;
            case ("div"):
                ctrler.html(value);
                break;
            case ("checkbox"):
                if (value) {
                    var args = value.split(",");
                    ctrler.val(args);
                }
                break;
            case ("radio"):
                if (value) {
                    $("input[name='" + e.ctrlId + "_group'][value=" + value + "]").attr("checked", true);
                }
                break;
            case ("apptable"):
                this.initTable(e);
                break;
            case ("record"):
                this.initRecord(e);
                break;
            case ("appfileupload"):
                var bandModelId = _this.replaceMapAndData(e.bandModelId);
                var bandGroupId = _this.replaceMapAndData(e.bandGroupId);
                if (bandGroupId.indexOf("{") >= 0) {
                    bandGroupId = 'V1.0';
                }
                if (bandModelId.indexOf('{') >= 0) {
                    $('#' + e.ctrlId + '_upload_button').attr('disabled', 'disabled');
                    $('#' + e.ctrlId + '_upload_button').addClass("fileUploadDisable");
                } else {
                    $('#' + e.ctrlId + '_upload_button').bind('click',
                        function () {
                            var u = navigator.userAgent;
                            var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;
                            if (isAndroid == false) {
                                ctrlUpload(e.ctrlId);
                            }
                        })
                }
                var fileHtml = getFileLi(e.ctrlId, bandModelId, bandGroupId);
                if (page.isnotNull(fileHtml)) {
                    $("#" + e.ctrlId + "_upload_ul").append(fileHtml);
                }
                break;
            default:
                ctrler.text(value);
        }
    };
    /* 依据控件配置信息获取控件
     * param e :控件配置信息
     * return :返回控件
     */
    this.getCtrl = function (e) {
        var ctrler = "[id=" + e.ctrlId + "]";
        return $(ctrler);
    };
    this.getFormConfig = function () {
        return formConfig
    };
    this.initRecord = function (e) {
        var bandModelId = _this.replaceMapAndData(e.bandModelId);
        var options = {
            "model_id": bandModelId,
            "ctrl_id": e.ctrlId
        };
        recordApp.init(options);
    };
    this.initTable = function (e) {

        var groupTable = groupBindTable[e.ctrlId];
        if (groupTable && groupTable.isOpen != "1") {
            return;
        }
        boot.__loadNeed("appTable");
        //绑定事件
        var tableId = e.ctrlId + "_appTable";
        var tableValMap = e.valMap;
        var options = {};
        options["listCode"] = e.listCode;
        options["tableID"] = e.ctrlId + "_appTable";
        options["bandCtrlId"] = e.ctrlId;
        options["title"] = "";//不显示标题
        options["pageSize"] = "";//不滑动加载
        tableValMap = _this.replaceMapAndData(tableValMap);
        options["getValMap"] = page.getUrlParamMap(tableValMap);
        if (run_model == '1') {
            options["config"] = WO.configSource[e.listCode];
            options["data"] = WO.dataSource[e.listCode];
        }
        options["run_model"] = run_model;
        // options["isOpen"] = isOpen;
        //options["bandCtrlId"] = $("#"+e.ctrlId+'_bandCtrlId').val();
        var appTable = new AppTable(options);
        tableMap[tableId] = appTable;
    };
    this.getTableMap = function () {
        return tableMap
    };
    this.getAppTablView = function (tableId) {
        if (tableId.indexOf("_appTable") > -1) {
            return tableMap[tableId];
        }
        return tableMap[tableId + "_appTable"];
    };
    //选择用户
    this.userSelectClick = function (ctrlId, selectMode, oldUserList, ret) {
        (function (doc, win) {
            window.base = document.documentElement.clientWidth / 1920;
            var docEl = doc.documentElement,
                resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
                recalc = function () {
                    window.clientWidth = docEl.clientWidth;
                    window.clientHeight = docEl.clientHeight;
                    var aspectRatio = window.clientWidth / window.clientHeight;
                    if (aspectRatio > 1920 / 1080) {
                        docEl.style.fontSize = 100 * (window.clientHeight / 1080) + 'px';
                        window.base = 100 * (window.clientHeight / 1080);
                    } else {
                        docEl.style.fontSize = 100 * (window.clientWidth / 1920) + 'px';
                        window.base = 100 * (window.clientWidth / 1920);
                    }
                    var isMobile = {
                        Android: function () {
                            return navigator.userAgent.match(/Android/i) ? true : false;
                        },
                        BlackBerry: function () {
                            return navigator.userAgent.match(/BlackBerry/i) ? true : false;
                        },
                        iOS: function () {
                            return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
                        },
                        Windows: function () {
                            return navigator.userAgent.match(/IEMobile/i) ? true : false;
                        },
                        any: function () {
                            return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());
                        }
                    };
                    if (isMobile.any()) {
                        if (window.orientation === 90 || window.orientation === -90) {
                            doc.getElementById('warnDrak').style.display = "block"
                        } else {

                        }
                    } else {
                        doc.getElementById('warnDrak').style.display = "block"
                    }
                };
            recalc();
            win.addEventListener(resizeEvt, recalc, false);
            doc.addEventListener('DOMContentLoaded', recalc, false);
        })(document, window);

        var userSelectList = "";

        if (oldUserList == "请选择" || oldUserList == "") {
            userSelectList = '<div class = "userSelectList form-radio" ><h5 class="userTitle userTitleAfter2">已选择人员：</h5></div>';
        } else {
            var userlist = _this.getUserList(oldUserList);
            var ht = '';
            for (var i = 0; i < userlist.length; i++) {
                ht += '<div class="mui-input-row mui-checkbox" style="float: left;"><label>' + userlist[i].name + '</label><input name="checkedUserList" username = "' + userlist[i].name + '" type="checkbox" value="' + userlist[i].value + '"></div>';
            }
            userSelectList = '<div class = "userSelectList form-radio" ><h5 class="userTitle userTitleAfter2">已选择人员：</h5>' + ht + '</div>';
        }
        var json = {
            "funName": 'queryUserList',
            "valMap": {},
            "pageIndex": "1",
            "pageSize": "20",
        }
        var res = webApi.ajax("system.common.queryList", json);
        var data = res.result.data;
        var letter = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'X', 'Y', 'Z', '#'];

        var listNumHtml = "";
        var listHtml = '';
        var reg = /^[A-Za-z]+$/;
        var liHeight = 0;
        var lettetHtml = '<ul>';
        //循环字母字符串
        for (var i = 0; i < letter.length; i++) {
            var liHtml = "";
            var numHtml = "";
            //循环用户数据，如果开头字母匹配，则生成html，如果不匹配，则略过
            for (var j = 0; j < data.length; j++) {
                var fontPin = chineseToPinYin(data[j].user_name.slice(0, 1));
                //判断开头字母是否为拼音，为否，加入到#中
                if (!reg.test(fontPin)) {
                    numHtml += '<div class="mui-input-row mui-checkbox mui-left selectList">'
                        + '<label>' + data[j].user_name + '</label>'
                        + '<input name="userCheckbox" userName = "' + data[j].user_name + '" value="' + data[j].user_id + '" type="checkbox">'
                        + '</div>';

                } else if (fontPin == letter[i]) {
                    liHtml += '<div class="mui-input-row mui-checkbox mui-left selectList">'
                        + '<label>' + data[j].user_name + '</label>'
                        + '<input name="userCheckbox" userName = "' + data[j].user_name + '" value="' + data[j].user_id + '" type="checkbox">'
                        + '</div>';
                }

            }
            if (liHtml != "" && letter[i] != "#") {
                lettetHtml += '<li>' + letter[i] + '</li>'
                var liHeight = liHeight + 20;
                var liHeightbox = liHeight + 20
                listHtml += '<div class="listEver" id="' + letter[i] + '">'
                    + '<p>' + letter[i] + '</p>'
                    + '<ul>' + liHtml + '</ul>'
                    + '</div>'

            }
            //***此处id不能为特殊符号，用数字32代替
            if (letter[i] == "#") {
                lettetHtml += '<li>' + letter[i] + '</li>'
                var liHeight = liHeight + 20;
                var liHeightbox = liHeight + 20
                //此处id不能为特殊符号，用数字32代替
                listHtml += '<div class="listEver" id="32">'
                    + '<p>' + letter[i] + '</p>'
                    + '<ul>' + numHtml + '</ul>'
                    + '</div>'
            }


        }
        listHtml = listHtml + listNumHtml
        lettetHtml += '</ul>'


        //dataList+='</form></div>';
        var opt = _this.getOrgList();
        var queryHtml = '<div class = "queryUser"><div  class="userSelect" style="border-radius:30px"><select id = "user_org" style="width:93%">' + opt + '</select></div><input id = "queryUserText" style="border-radius:30px" class="userInput" type="text"/><span class="mui-icon mui-icon-search mui-searchImg mui-searchImgs clickImg"></span></div>';
        var userList = '<div class = "allUserList mui-card" ><h5 class="userTitle userTitleAfter1">选择人员：</h5>'
            + '<div class="letter" style="height:' + liHeightbox + 'px;top:50%;margin-top:-' + liHeightbox / 2 + 'px">' + lettetHtml + '</div>'
            //+'<div class="letter" id="letter">'+lettetHtml+'</div>'
            + '<form class="mui-input-group selectListGroup list"><input id = "hide_ctrlId_mode" type = "hidden"  ctrlId = "' + ctrlId + '" selectMode = "' + selectMode + '">' + listHtml + '</form></div>';
        //		//var userSelectList = '<div class = "userSelectList form-radio" ><h5 class="userTitle userTitleAfter2">已选择人员：</h5></div>';
        var btnHtml = '<div class = "form-btn form-btn-3" style="overflow:hidden;zoom:1"><button  id = "userSubmit" class="mui-btn mui-btn-primary btnqueding" >确定</button><button id = "userJoin" class="mui-btn mui-btn-primary btnJoin"  >加入</button><button id="userRemove" class="mui-btn mui-btn-primary btnRemove">移除</button></div>';

        page.openPopWindows("选择用户", queryHtml + userList + userSelectList + btnHtml, "98%", "98%");
        $(".letter li").click(function () {
            var thisFont = $(this).html();
            if (thisFont == "#") {
                thisFont = "32";
            }
            $(".list").animate({
                scrollTop: $("#" + thisFont).offset().top
            }, {
                duration: 500,
                easing: "swing"
            });
            return false;
        })

        $("#userJoin").click(function () {
            _this.userJoin();
        });
        $("#userRemove").click(function () {
            _this.userRemove();
        });
        $("#userSubmit").click(function () {
            _this.userSubmit();
        });
        $(".clickImg").click(function () {
            _this.getQueryUserList();
        });
        $("#user_org").change(function () {
            _this.getOnChangeUserList();
        });
    };
    //加入
    this.userJoin = function () {
        var html = '';
        var checkedUserStr = '';
        if ($("input[name='userCheckbox']:checked").length == 0) {
            dialogBox.showMessDialog("未选择用户！");
            return;
        }
        var mode = $("#hide_ctrlId_mode").attr("selectMode");
        if (mode == "s") {
            if ($("input[name='checkedUserList']").length >= 1 || $("input[name='userCheckbox']:checked").length > 1) {
                dialogBox.showMessDialog("只能选择一个用户");
                return;
            }
        }

        if ($("input[name='checkedUserList']").length > 0) {
            $("input[name='checkedUserList']").each(function (index2, item2) {
                checkedUserStr += $(item2).val() + "_";
            })
            $("input[name='userCheckbox']:checked").each(function (index, item) {
                if (checkedUserStr.indexOf($(item).val()) < 0) {
                    html += '<div class="mui-input-row mui-checkbox" style="float: left;"><label>' + $(item).attr("userName") + '</label><input name="checkedUserList" username = "' + $(item).attr("userName") + '" type="checkbox" value="' + $(item).val() + '"></div>';
                }
            });

        } else {
            $("input[name='userCheckbox']:checked").each(function (index, item) {
                html += '<div class="mui-input-row mui-checkbox" style="float: left;"><label>' + $(item).attr("userName") + '</label><input name="checkedUserList"  username = "' + $(item).attr("userName") + '" type="checkbox" value="' + $(item).val() + '"></div>';
            })
        }
        $(".userSelectList").append(html);
    };
    //移除
    this.userRemove = function () {
        if ($("input[name='checkedUserList']:checked").length > 0) {
            $("input[name='checkedUserList']:checked").each(function (index2, item2) {
                $(item2).parent().remove();
            })
        } else {
            dialogBox.showMessDialog("未选择需要移除的用户！");
        }
    };
    //确定
    this.userSubmit = function () {
        var selectStr = '';
        $("input[name='checkedUserList']").each(function (index2, item2) {
            var userVal = $(item2).val();
            var username = $(item2).attr("username");
            selectStr += username + '[' + userVal + '],';
        })
        selectStr = selectStr.substring(0, selectStr.length - 1);
        var ctrlId = $("#hide_ctrlId_mode").attr("ctrlId");
        if (!selectStr) {
            $("#" + ctrlId).text("请选择");
            $("#" + ctrlId).val("");
        } else {
            $("#" + ctrlId).val(selectStr);
            $("#" + ctrlId).text(selectStr);
        }
        $(".closeImg").click();
    };
    //获取已经选择的值
    this.getUserList = function (oldUserList) {
        var List = [];
        var userList = oldUserList.split(",");
        for (var i = 0; i < userList.length; i++) {
            var obj = new Object();
            var userValue = userList[i].split("[")[1];
            obj.name = userList[i].split("[")[0];
            obj.value = userValue.replace("]", "");
            List.push(obj);
        }
        return List;
    };
    this.getQueryUserList = function () {
        var selectOrg = $("#user_org").val();
        var queryUserValue = $("#queryUserText").val();
        var json = {
            "funName": 'queryUserLikeUserName',
            "valMap": {
                "user_name": '%' + queryUserValue + '%'
            },
            "pageIndex": "1",
            "pageSize": "20",
        }
        var res = webApi.ajax("system.common.queryList", json);
        var data = res.result.data;
        $(".selectList").remove();
        var dataList = '';
        for (var i = 0; i < data.length; i++) {
            dataList += '<div class="mui-input-row mui-checkbox mui-left selectList">'
                + '<label>' + data[i].user_name + '</label>'
                + '<input name="userCheckbox" userName = "' + data[i].user_name + '" value="' + data[i].user_id + '" type="checkbox">'
                + '</div>';
        }
        $(".selectListGroup").append(dataList);
    };
    //获取组织
    this.getOrgList = function () {
        var optionStr = '';
        var company = sessionStorage.getItem("_company");
        company = '新华医院';
        var json = {
            "funName": 'queryorgByOrgName',
            "valMap": {
                "oname": company
            }
        }
        if (orgList.length <= 0) {
            var res = webApi.ajax("system.common.queryList", json);
            var data = res.result.data;
            for (var i = 0; i < data.length; i++) {
                if (data[i].opid == '-') {
                    orgList.push(data[i]);
                    this.getOrgListDG(data, data[i].oid, 1);
                }
            }
        }
        for (var k = 0; k < orgList.length; k++) {
            optionStr += '<option value="' + orgList[k].oid + '" >' + orgList[k].oname + '</option>';
        }
        return optionStr;
    };
    this.getOrgListDG = function (data, id, n) {
        for (var i = 0; i < data.length; i++) {
            if (data[i].opid == id) {
                data[i].oname = n + "_" + data[i].oname;
                orgList.push(data[i]);
                this.getOrgListDG(data, data[i].oid, n + 1);
            }
        }
    };
    this.getOnChangeUserList = function () {
        var oid = $("#user_org").val();
        var json = {
            "funName": 'queryuserListByOid',
            "valMap": {
                "oid": oid
            }
        }
        var res = webApi.ajax("system.common.queryList", json);
        var data = res.result.data;
        var data2 = [];
        for (var i = 0; i < data.length; i++) {//清理垃圾数据
            if (data[i].user_id) {
                data2.push(data[i]);
            }
        }
        if (data2.length > 0) {
            $(".selectList").remove();
            var dataList = '';
            for (var i = 0; i < data2.length; i++) {
                dataList += '<div class="mui-input-row mui-checkbox mui-left selectList">'
                    + '<label>' + data2[i].user_name + '</label>'
                    + '<input name="userCheckbox" userName = "' + data2[i].user_name + '" value="' + data2[i].user_id + '" type="checkbox">'
                    + '</div>';
            }
            $(".selectListGroup").append(dataList);

        }
    };
    this.clickGroup = function () {
        $("p[class='detailedTtitle'][id$='_group']").click(function () {
            var key = this.getAttribute("id");
            if (page.isnotNull(key)) {
                key = key.substring(0, key.length - 6);
            }
            var html = $("#" + key + '_appTable').html();
            if (page.isnotNull(html)) {
                $("#" + key + '_appTable').html('');
            } else {
                var table = groupBindTable[key];
                boot.__loadNeed("appTable");
                var tableId = table.ctrlId + "_appTable";
                var tableValMap = table.valMap;
                var options = {};
                options["listCode"] = table.listCode;
                options["tableID"] = table.ctrlId + "_appTable";
                options["bandCtrlId"] = table.ctrlId;
                options["title"] = "";//不显示标题
                options["pageSize"] = "";//不滑动加载
                tableValMap = _this.replaceMapAndData(tableValMap);
                options["getValMap"] = page.getUrlParamMap(tableValMap);
                if (run_model == '1') {
                    options["config"] = WO.configSource[table.listCode];
                    options["data"] = WO.dataSource[table.listCode];
                }
                options["run_model"] = run_model;
                var appTable = new AppTable(options);
                tableMap[tableId] = appTable;
            }
        });
    };
    this.bodyBindEvent = function () {
        $(document).on('mousedown', function (e) {
            if (!$(e.target).is($('.upload_fileImgBtn')) && !$(e.target).is($('.isAndroidUL'))) {
                if ($(".isAndroidUL").length > 0) {
                    $('.isAndroidUL').slideUp();
                }

            }
        });
        $(window).scroll(function () {
            if ($(".isAndroidUL").length > 0) {
                $(".isAndroidUL").hide();
            }
        })
    }
}

function getFileLi(ctrlId, bandModelId, bandGroupId) {
    var fileHtml = "";
    var json = {
        "funName": "queryFileByModelId",
        "funType": "C",
        "valMap": {
            "_inmodel_id": bandModelId,
            "group_id": bandGroupId
        }
    }
    var ret = webApi.ajax("system.common.queryList", json);
    if (ret && ret.status == "0" && ret.result && ret.result.data && ret.result.data.length > 0) {
        var files = ret.result.data;
        var dataListStr = new Array();//url集合
        for (var m = 0; m < files.length; m++) {
            var file_url = files[m].file_url;
            var hz = file_url.substring(file_url.lastIndexOf('.') + 1);
            var url;
            if (hz == 'html') {
                url = company + "/html/common/htmlView.html?url=" + sitePath + "/" + encodeURI(encodeURI(file_url));
            } else if (hz == "pdf") {
                url = company + "/js/pdfjs/web/viewer.html?file=" + sitePath + "/" + file_url;
            } else if (hz == "jpg" || hz == "jpeg" || hz == "png") {
                url = company + "/html/common/imageView.html?file_id=" + files[m].file_id;
            }
            dataListStr.push(url)
        }
        var datalist = dataListStr.join(';')
        for (var i = 0; i < files.length; i++) {
            var file_size = files[i].file_size;
            if (!page.isnotNull(file_size) || isNaN(file_size)) {
                file_size = 0;
            }
            var fileSize = parseInt(file_size / 1024) + "KB";
            var fileName = files[i].file_name;
            var fileId = files[i].file_id;
            var fileURL = files[i].file_url;
            var fileSuffix = files[i].file_suffix_name;
            fileHtml += '<li><h4>' + fileName + '<span>' + fileSize + '</span></h4><div class="fileDiv">' +
                '<a id="' + ctrlId + '_upload_a_' + i + '" onclick="filePreView(\'' + bandModelId + '\',\'' + bandGroupId + '\',\'' + ctrlId + '\',\'' + i + '\',\'' + fileId + '\',\'' + fileSuffix + '\',\'' + fileURL + '\',\'' + datalist + '\')">预览</a>' +
                '<span onclick="fileDelete(\'' + fileId + '\',\'' + ctrlId + '\',\'' + bandModelId + '\',\'' + bandGroupId + '\')"></span></div></li>';
        }
    }
    return fileHtml;
}

function ctrlUpload(ctrlId) {
    $("#" + ctrlId + "_upload_input").click();
}

function inputFileUpload(fileConfigCode, fileDirectory, bandModelId, bandGroupId, ctrlId) {
    if ($("#" + ctrlId + "_upload_input").length <= 0) {
        dialogBox.showMessDialog("请选择上传文件", 2000);
        return;
    }
    var jsonData = {"fileConfigCode": fileConfigCode, "model_id": bandModelId, "group_id": bandGroupId};
    $.ajaxFileUpload({
        url: company + '/system/file/fileUpload',
        async: false, //是否是异步
        fileElementId: ctrlId + "_upload_input",
        data: {

            jsonStr: JSON.stringify(jsonData)
        },
        dataType: "json",
        success: function (data, status) {

            if (data) {
                var ret = data;
                if (ret.status == "0") {
                    dialogBox.showMessDialog("上传成功!");
                    $("#" + ctrlId + "_upload_ul").empty();
                    var fileHtml = getFileLi(ctrlId, bandModelId, bandGroupId);
                    if (page.isnotNull(fileHtml)) {
                        $("#" + ctrlId + "_upload_ul").append(fileHtml);
                    }
                } else {
                    var message = ret.message;
                    dialogBox.showMessDialog("上传失败:" + message);
                }
            } else {
                dialogBox.showMessDialog("上传失败!");
            }
        },
        error: function (data, status, e) {
            var ret = JSON.parse(data.responseText);
            if (ret.status != "0") {
                dialogBox.alert("上传异常：" + ret.message);
            } else {
                dialogBox.alert("上传成功!");
            }
        }
    });
    dialogBox.showMessDialog("上传中请稍后...");
}

/*
*   将中文转化为英文
*   参数l1:需要转化的英文(传入的拼音不会被转换)
*   例如：参数为他们xiao   输出TaMenxiao
*/
function chineseToPinYin(l1) {
    var l2 = l1.length;
    var I1 = "";
    var reg = new RegExp('[a-zA-Z0-9\- ]');
    for (var i = 0; i < l2; i++) {
        var val = l1.substr(i, 1);
        var name = arraySearch(val, PinYin);
        if (reg.test(val)) {
            I1 += val;
        } else if (name !== false) {
            I1 += name;
        }

    }
    I1 = I1.replace(/ /g, '-');
    while (I1.indexOf('--') > 0) {
        I1 = I1.replace('--', '-');
    }
    return I1;
}

function arraySearch(l1, l2) {
    for (var name in PinYin) {
        if (PinYin[name].indexOf(l1) != -1) {
            return ucfirst(name);
            break;
        }
    }
    return false;
}

function initFormStyle() {
    var showTop = page.getUrlParam("showTop");
    if (showTop == "1") {
        $(".showTop").css("padding-top", "1px");
    }
}

/*
*   将英文的首字母大写，其余的不变
*   参数l1:需要转首字母大写的英文
*   例如：参数为xiao他们  输出Xiao他们
*/
function ucfirst(l1) {
    if (l1.length > 0) {
        var first = l1.substr(0, 1).toUpperCase();
        var spare = l1.substr(1, l1.length);
        return first + spare;
    }
}

function gotoShow() {
    wx.chooseImage({
        count: 1, // 默认9
        sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
        sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
        success: function (res) {
            var localIds = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
        }
    });
}

// 相册
function PhotoFn() {
    console.log(111)
}

// 拍照
function PicFn() {
    console.log(111)
}

// 文件
function FileFn() {
    console.log(111)
}

function uploadImgFiles(fileConfigCode, fileDirectory, bandModelId, bandGroupId, ctrlId) {
    var html = '';
    html = '<ul class="isAndroidUL" style="top:' + parseInt(event.clientY + 15) + 'px">' +
        '<li onclick="javascript:uploadImgOpen(\'' + fileConfigCode + '\',\'' + fileDirectory + '\',\'' + bandModelId + '\',\'' + bandGroupId + '\',\'' + ctrlId + '\')">拍照或打开相册</li>' +
        '<li>打开文件夹<input type="file" value="上传" id="' + ctrlId + '_upload_input" name="file" accept="*" style="opacity:0" ' +
        'onchange="inputFileUpload(\'' + fileConfigCode + '\',\'' + fileDirectory + '\',\'' + bandModelId + '\',\'' + bandGroupId + '\',\'' + ctrlId + '\')" onblur="inputOnblur()" />' +
        '</li>' +
        '</ul>';
    if ($(".isAndroidUL").length > 0) {
        if ($(".isAndroidUL").is(":hidden")) {
            $(".isAndroidUL").show();
        } else {
            $(".isAndroidUL").hide();
        }
    } else {
        $("body").append(html);
    }

}

function uploadImgOpen(fileConfigCode, fileDirectory, bandModelId, bandGroupId, ctrlId) {
    $(".isAndroidUL").hide();
    var jsonData = {"fileConfigCode": fileConfigCode, "model_id": bandModelId, "group_id": bandGroupId};
    jsonData = JSON.stringify(jsonData);
    var currentUrl = page.getUrlParam("currentUrl");
    page.openWXChooseImg(currentUrl, jsonData)
}

function inputOnblur() {
    $(".isAndroidUL").hide();
}

function filePreView(bandModelId, bandGroupId, ctrlId, index, fileId, suffix, file_url, dataListStr) {
    var aId = ctrlId + "_upload_a_" + index;
    if (suffix == "pdf") {
        var hz = file_url.substring(file_url.lastIndexOf('.') + 1);
        var URL;
        if (hz == 'html') {
            var ListStr = dataListStr.split(';')
            URL = company + "/html/common/htmlView.html?url=" + sitePath + "/" + encodeURI(encodeURI(file_url));
            page.sliderMethod("预览", ListStr, URL);
        } else {
            URL = company + "/js/pdfjs/web/viewer.html?file=" + sitePath + "/" + file_url;
            page.opensubPage(URL, '预览');
        }
    } else if (suffix == "jpg" || suffix == "jpeg" || suffix == "png") {
        var URL = company + "/html/common/imageView.html?file_id=" + fileId;
        page.opensubPage(URL, '预览');
        //page.openWindow(URL);
    } else {
        dialogBox.alert("当前格式暂不支持预览!");
    }
}

function fileDelete(file_id, ctrlId, bandModelId, bandGroupId) {
    dialogBox.confirm("请确认是否删除? ", function () {
        if (page.isnotNull(file_id)) {
            var fileJson = {
                "file_id": file_id
            }
            webApi.ajax("system.file.fileDelete", fileJson, function (data) {
                if (data.status != "0") {
                    dialogBox.showMessDialog(data.message, 1500);
                } else {
                    dialogBox.showMessDialog("删除成功！");
                    $("#" + ctrlId + "_upload_ul").empty();
                    var fileHtml = getFileLi(ctrlId, bandModelId, bandGroupId);
                    if (page.isnotNull(fileHtml)) {
                        $("#" + ctrlId + "_upload_ul").append(fileHtml);
                    }
                }
            });
        } else {
            dialogBox.showMessDialog("删除失败,数据异常!")
        }
    })
}

function initFormFunName(funName) {

    return null;
}

//二次开发重写表单配置调用接口url
function initQueryConfigUrl(url) {
    return url;
}

//二次开发重写表单配置调用接口 参数
function initConfig(json) {
    return json;
}

//二次开发重写表单配置调用接口url
function initQueryDataUrl(url) {
    return url;
}

//二次开发重写表单数据查询调用接口url
function initQueryData(json) {
    return json;
}

//二次开发重写异步数据源的URL
function initDataSourceUrl(url) {
    return url;
}

//二次开发重写异步数据源的查询配置
function initDataSource(json) {
    return json;
}

/**
 * 界面初始化后二次开发函数
 */
function formOnload() {
}

/**
 * 处理下拉选择检索
 */
function initSelect(e) {
    return false;
}

//初始化传递参数
function initParmMap(ParmMap) {
    return ParmMap;
}

// 初始化表单状态
function initFormState(state) {
    // state='update'
    return state;
}

// 初始化获取数据返回值
function initFormData(data) {
    return data;
}


// 保存之前的操作函数
function initSaveForm(data, state) {
    return data;
}

// 删除按钮 数据处理
function initDelForm(data) {
    return data;
}

// 删除表单回调函数
function delFormCallBack(data) {
    return data;
}

// 页面初始化完成执行
function formOnload() {

}

// 保存之后操作函数
function doSavedAction(data, state) {

}

// 是否需要重定向
function initUrlRedirect(params) {
    return true;
}

function confirmAction() {

}

function saveForm() {
    var data = Form.getAppFormData();
    var state = "update";

    if (!data) {
        return false;
    }

    var formData = Form.getFormConfig();
    var csystem = formData.csystem
    var sff_db_name = formData.sff_db_name
    var sff_condition = formData.sff_condition

    var re = /{(.*?)}/g;
    var reg = /^\{/gi;
    var reg2 = /\}$/gi;

    // conditionList为{}数组
    var conditionList = [];
    while (temp = re.exec(sff_condition)) {
        temp[0] = temp[0].replace(reg, '');
        temp[0] = temp[0].replace(reg2, '');
        conditionList.push(temp[0])
    }

    if (conditionList.length > 0) {
        var valMapJson = {};
        var list1 = sff_condition.split("&");
        for (var i = 0; i < list1.length; i++) {
            var list2 = list1[i].split("=");
            valMapJson[list2[1]] = list2[0];
        }

        for (i in conditionList) {
            if (!parmMap[conditionList[i]] && !data[conditionList[i]]) {
                data[valMapJson["{" + conditionList[i] + "}"]] = '{UUID}'
                state = "new";
            }
        }
    }

    data = initSaveForm(data, state);
    if (!data) {
        return false;
    }

    var json = {
        "funName": sff_db_name,
        "funSystem": csystem,
        "valMap": data,
        "lsTime": Form.getlsTime()
    };
    var ret = webApi.ajax("system.common.submitForm", json);
    if (ret.status != '0') {
        mui.alert(ret.message, '提示', '确定', null, 'div')
        if (ret.status == "-2") {
            window.location.reload();
        }
        return false;
    } else {
        if (ret["lstime"]) {
            Form.setlsTime(ret["lstime"]);
        }
        dialogBox.showMessDialog("保存成功!");
    }
    if ("new" == state) {

        // 返回的主键存进parmMap以及data中
        for (var dk in ret.result.data) {
            data[dk] = ret.result.data[dk];
            parmMap[dk] = ret.result.data[dk];
        }

    }

    doSavedAction(data, state);
    var params = new Array;

    // 将更新后的data数据存入parmMap
    for (var k in parmMap) {
        for (var dk in data) {
            if (k == dk) {
                parmMap[k] = data[dk];
            }
        }
    }

    // 如果conditionList中有符合parmMap的KEY 则存入params；
    for (var k in parmMap) {
        for (l in conditionList) {
            if (conditionList[l] == k) {
                var pa = {
                    "key": k,
                    "value": parmMap[k]
                }
                params.push(pa)
            }
        }

    }
    var isUrlRedirect = initUrlRedirect(params);
    if (isUrlRedirect) {
        page.urlRedirect(params);
    }
}

function delForm() {
    var data = Form.getAppFormData();
    if (!data) {
        return false;
    }
    var formData = Form.getFormConfig();
    var csystem = formData.csystem
    var sff_db_name = formData.sff_db_name

    mui.confirm('确定删除?', '提示', ["取消", "确定"], function (e) {
        if (e.index == 1) {
            data = initDelForm(data);
            if (data) {
                var json = {
                    "funName": sff_db_name,
                    "funSystem": csystem,
                    "valMap": data
                };
                var ret = webApi.ajax("system.common.deleteForm", json);
                if (ret.status != '0') {
                    mui.alert(ret.message, '提示', '确定', null, 'div')
                }
                mui.alert('删除成功', '提示', '确定', null, 'div')
                data = delFormCallBack(data);
                if (data) {
                    newForm();
                }
            }
        }
    }, 'div')
}

function newForm() {

    for (var key in parmMap) {
        if (key == 'temptoken') {
            delete parmMap[key];
            break;
        }
    }

    var formData = Form.getFormConfig();
    var sff_condition = formData.sff_condition
    var re = /{(.*?)}/g;
    var reg = /^\{/gi;
    var reg2 = /\}$/gi;

    var conditionList = [];
    while (temp = re.exec(sff_condition)) {
        temp[0] = temp[0].replace(reg, '');
        temp[0] = temp[0].replace(reg2, '');
        conditionList.push(temp[0])
    }

    if (conditionList.length > 0) {
        for (i in conditionList) {
            if (parmMap[conditionList[i]]) {
                parmMap[conditionList[i]] = "";
            }
        }
    }
    var params = new Array;

    for (k in parmMap) {
        var pa = {
            "key": k,
            "value": parmMap[k]
        }
        params.push(pa)
    }
    urlParmList = initParmMap(params);
    page.urlRedirect(params);

}

//初始化按钮样式
function initBtns() {
    $(".mui-searchRegion").append("<div class='btnHide' id='btnHide'></div>")
    $("#buttonArea").css({
        "width": "60px",
        "position": "absolute",
        "right": "0",
        "z-index": "9999",
        "background-color": "#fff",
        "box-shadow": "0 0 5px #ddd",
        "display": "none"
    });
    $("#buttonArea button").css({"margin": "5px auto", "display": "block"});
    $(".btnHide").click(function () {
        $("#buttonArea").slideToggle();
    });
    $(document).on('mousedown', function (e) {
        if (!$(e.target).is($('#btnHide')) && !$(e.target).is($('#buttonArea')) && $(e.target).parent('#buttonArea').length === 0) {
            $('#buttonArea').slideUp();
        }
    });
}
